/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package poo.biblioteca.vistas.autores;

import biblioteca.entidades.Pais;
import java.util.ArrayList;

/**
 *
 * @author apo
 */
public class PnlAutor extends javax.swing.JPanel {

    /**
     * Creates new form PnlAutor
     */
    public PnlAutor() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtIdAutor = new javax.swing.JTextField();
        lblIdAutor = new javax.swing.JLabel();
        txtNombreAutor = new javax.swing.JTextField();
        txtApellidosAutor = new javax.swing.JTextField();
        cmbPais = new javax.swing.JComboBox();
        lblNombreAutor = new javax.swing.JLabel();
        lblApellidoAutor = new javax.swing.JLabel();
        lblNacionalidad = new javax.swing.JLabel();

        setBorder(javax.swing.BorderFactory.createTitledBorder("Datos de Autor"));

        txtIdAutor.setEnabled(false);

        lblIdAutor.setText("Id Autor:");

        lblNombreAutor.setText("Nombre Autor:");

        lblApellidoAutor.setText("Apellido Autor:");

        lblNacionalidad.setText("Nacionalidad:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblIdAutor)
                    .addComponent(lblNombreAutor)
                    .addComponent(lblApellidoAutor)
                    .addComponent(lblNacionalidad))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtApellidosAutor)
                    .addComponent(txtNombreAutor)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cmbPais, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtIdAutor, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 125, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtIdAutor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblIdAutor))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNombreAutor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNombreAutor))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtApellidosAutor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblApellidoAutor))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNacionalidad)))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cmbPais;
    private javax.swing.JLabel lblApellidoAutor;
    private javax.swing.JLabel lblIdAutor;
    private javax.swing.JLabel lblNacionalidad;
    private javax.swing.JLabel lblNombreAutor;
    private javax.swing.JTextField txtApellidosAutor;
    private javax.swing.JTextField txtIdAutor;
    private javax.swing.JTextField txtNombreAutor;
    // End of variables declaration//GEN-END:variables

    public String getIdAutor() {
        return txtIdAutor.getText();
    }

    public void setIdAutor(String idAutor) {
        txtIdAutor.setText(idAutor);
    }

    public String getNombreAutor() {
        return txtNombreAutor.getText();
    }

    public void setNombreAutor(String nombreAutor) {
        txtNombreAutor.setText(nombreAutor);
    }

    public String getApellidoAutor() {
        return txtApellidosAutor.getText();
    }

    public void setApellidoAutor(String apellidoAutor) {
        txtApellidosAutor.setText(apellidoAutor);
    }

    public Pais getPaisSeleccionado() {
        return (Pais) cmbPais.getSelectedItem();
    }

    public void addPaises(ArrayList<Pais> paises) {
        for (Pais pais : paises) {
            cmbPais.addItem(pais);
        };
    }

    public void setPaisSeleccionado(Pais pais) {
        cmbPais.setSelectedItem(pais);
    }
}
